<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>扩展运算符</title>
</head>

<body>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <button class="btn">关闭</button>
  <script>
    // 利用扩展运算符将伪数组转换成真正的数组
    var oDivs = document.getElementsByTagName('div');
    console.log(oDivs);

    var arr1 = [...oDivs];
    console.log(arr1);

    // 将伪类数组转换成真正的数组后就可以调用数组的方法及属性，如 push() del() ...
    arr1.push('a');
    console.log(arr1);

    console.log("---------------------------华丽丽的的分割线---------------------------");

    // 测试页面关闭功能
    const btn = document.querySelector('.btn');
    console.log(btn);
    btn.onclick = function () {
      console.log("关闭了");
      // 一：
      // var opened = window.open('about:blank', '_self');
      // opened.close();

      // 二：
      window.opener = null;
      window.open(" ", "_self");
      window.close();
    }

  </script>
</body>

</html>